package com.tucc.hello.other;

/**
 * @author tucc
 * @description todo
 * @package com.tucc.hello
 * @date 2021/5/21
 **/
public class Test {

    public static void main(String[] args) {
        System.out.println(testFinally1());
        System.out.println(testFinally2());
        System.out.println(testFinally3());
        System.out.println(testFinally4());
        System.out.println(testFinally5());

    }

    public static int testFinally1(){
        int result = 0;
        try{
            int a = 10 / 0;
            result = 1;
            return result;
        }catch (Exception e){
            result = 2;
            return result;
        }
        finally {
            result = 3;
        }
    }

    public static int testFinally2(){
        int result = 0;
        try{
            int a = 10 / 0;
            result = 1;
            return result;
        }catch (Exception e){
            result = 2;
            return result;
        }
        finally {
            result = 3;
            return result;
        }
    }

    public static int testFinally3(){
        int result = 0;
        try{
            int a = 10 / 0;
            result = 1;
        }catch (Exception e){
            result = 2;
        }
        finally {
            result = 3;
        }
        return result;
    }

    public static int testFinally4(){
        int result = 0;
        try{
            int a = 10 / 1;
            result = 1;
            return result;
        }catch (Exception e){
            result = 2;
            return result;
        }
        finally {
            result = 3;
            return result;
        }
    }

    public static int testFinally5(){
        int result = 0;
        try{
            int a = 10 / 1;
            result = 1;
            return result;
        }catch (Exception e){
            result = 2;
            return result;
        }
        finally {
            result = 3;
        }
    }
}
